package com.lge.pitchingcoins.util.databases;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class PitchingCoinsDatabaseHelper extends SQLiteOpenHelper {
    public static final String DB_NAME = "pitchingcoins";
    public static final String SCORE_TABLE_NAME = "score";
    public static final int DB_VERSION = 4;
    
    public static final String KEY_NICKNAME = "name";
    public static final String KEY_SCORE = "score";
    
    public PitchingCoinsDatabaseHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
    }
    
    
    @Override
    public void onCreate(SQLiteDatabase database) {
        String queryForCreateDatabase = "create table " + SCORE_TABLE_NAME + " (_id integer primary key autoincrement, " + KEY_NICKNAME + " text not null, " + KEY_SCORE + " integer);";
        
        database.execSQL(queryForCreateDatabase);
    }

    @Override
    public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
        String queryForDropDatabase = "drop table if exists " + SCORE_TABLE_NAME;
        
        database.execSQL(queryForDropDatabase);
        onCreate(database);
    }   
}